"""
审计日志 VO
"""

import utils.enum_utils as enum
from models import (
    VOBase,
    VOPage,
)
from my_typing import *
from utils.data_utils.special import ObjectIdStr
from utils.mock_utils import Demo
from utils.validator_utils.pydantic_validator.field import (
    CharField,
    IntegerField,
    NormalField,
)


class AuditLogListVO(VOBase):
    """ 审计日志 | 列表 | VO """

    audit_log_id: ObjectIdStr = CharField(..., title="审计日志 ID（ObjectId 字符串）", examples=[Demo.id])

    create_time: str = CharField(..., title="创建时间", min_length=19, max_length=19, examples=[Demo.date_str])
    ip: str = CharField(..., title="IP 地址", min_length=7, max_length=15)
    model: enum.Model = NormalField(..., title="模型")
    operation: enum.ModelOperation = NormalField(..., title="操作类型")
    po_id_list: list[ObjectIdStr] = CharField(..., title="PO ID 列表")
    request_id: StrOrNone = CharField(title="请求 ID", min_length=28, max_length=28)
    user_id: ObjectIdStr | None = CharField(..., title="用户 ID", examples=[Demo.id])


class AuditLogDetailVO(AuditLogListVO):
    """ 审计日志 | 详情 | VO """

    exception: bool = NormalField(title="是否发生异常")
    status_code: enum.HTTPStatusCode = IntegerField(..., title="响应状态码")


class AuditLogListPage(VOPage[AuditLogListVO]):
    """ 审计日志 | 列表 | 分页 """
